/**
 *                     Remixvym (version 0.9.1)
 *             Copyright (c) 2010 by RemixLab, DISI-UNAL
 *            http://www.disi.unal.edu.co/grupos/remixlab/
 *
 * This Java package provides classes to visualize Mind Maps created in VYM
 * (View Your Mind) in a Processing Sketch
 *
 * @author Gabriel Bobadilla
 *
 * This source file is free software; you can redistribute it and/or modify it
 * under the terms of the GNU General Public License as published by the Free
 * Software Foundation; either version 3 of the License, or (at your option)
 * any later version.
 *
 * This code is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
 * more details.
 *
 * A copy of the GNU General Public License is available on the World Wide Web
 * at <http://www.gnu.org/copyleft/gpl.html>. You can also obtain it by
 * writing to the Free Software Foundation, 51 Franklin Street, Fifth Floor
 * Boston, MA 02110, USA
 */
package remixlab.remixvym.core.graphics.node;

import processing.core.PApplet;
import remixlab.remixvym.core.mindmap.Node;

/**
 * This class draws the node borders like a semi-rounded rectangles.
 * <p>
 * Extends {@link remixlab.remixvym.core.graphics.node.NodeShape}<p>
 * <b>See examples: </b> NodeStyle
 */
public class RFishHeadNode extends NodeShape {

	/**
	 * Draws the node border like a semi-rounded rectangles.
	 * <p>
	 * 
	 * @param node
	 * @param parent
	 */	
	double factory = 0.49;

	/**Decomposes the drawing of the rounded rectangle*/
	public void draw(Node node, PApplet parent){
		int nxSize = node.width;
		int nySize = node.height;
		int nxPos = node.x1;
		int nyPos = node.y1;

		parent.smooth();
		parent.noStroke();

		//Internal area (its like a cross)
		parent.beginShape();
		parent.vertex(nxPos,nyPos);

		parent.vertex(nxPos+nxSize-(int)(nySize*factory),nyPos);
		parent.vertex(nxPos+nxSize-(int)(nySize*factory),nyPos+(int)(nySize*factory));
		parent.vertex(nxPos+nxSize,nyPos+(int)(nySize*factory));
		 
		parent.vertex(nxPos+nxSize, nyPos+nySize-(int)(nySize*factory));
		parent.vertex(nxPos-(int)(nySize*factory)+nxSize, nyPos+nySize-(int)(nySize*factory));
		parent.vertex(nxPos-(int)(nySize*factory)+nxSize, nyPos+nySize);
		
		parent.vertex(nxPos, nyPos+nySize);
		parent.endShape();

		//Linear borders
		parent.stroke(0);
		parent.line(nxPos, nyPos, nxPos+nxSize-(int)(nySize*factory),nyPos);
		parent.line(nxPos+nxSize,nyPos+(int)(nySize*factory), nxPos+nxSize, nyPos+nySize-(int)(nySize*factory));
		parent.line(nxPos-(int)(nySize*factory)+nxSize, nyPos+nySize, nxPos, nyPos+nySize);
		parent.line(nxPos, nyPos, nxPos,nyPos+nySize);

		// The two round corners
		parent.arc(nxPos+nxSize-(int)(nySize*factory),nyPos+(int)(nySize*factory), (int)(2*nySize*factory), (int)(1.9*nySize*factory), PApplet.TWO_PI-PApplet.PI/2, PApplet.TWO_PI);
		parent.arc(nxPos-(int)(nySize*factory)+nxSize, nyPos+nySize-(int)(nySize*factory), (int)(2*nySize*factory), (int)(1.9*nySize*factory), 0, PApplet.PI/2);
	}
	
}
